import { http } from '@/utils/request'
import type { LoginWxMinParams } from '@/types'

// 小程序登录
export const weixinMiniAppLogin = (data: LoginWxMinParams) => {
    return http({
        method: 'POST',
        url: '/app-api/member/auth/weixin-mini-app-login',
        data,
    })
}
// 刷新token
export const refreshToken = (refreshToken:string) => {
    return http({
        method: 'POST',
        url: `/app-api/member/auth/refresh-token?refreshToken=${refreshToken}`,
    })
}
// 字典表数据
export const getDictList = (type: string) => {
    return http({
        method: 'GET',
        url: '/app-api/system/dict-data/type',
        data: { type },
    })
}
// 获得微信小程序码(base64 image)
export const getQrcode = (data: any) => {
    return http({
        method: 'POST',
        url: '/app-api/member/social-user/wxa-qrcode',
        data
    })
}
// 创建会员邀请
export const createInviter = (data: any) => {
    return http({
        method: 'POST',
        url: '/app-api/member/inviter/create',
        data
    })
}
// 获得省
export const getProvince = () => {
    return http({
        method: 'GET',
        url: '/app-api/member/cities-districts/getProvince'
    })
}
// 获得市
export const getCity = (provinceCode: any) => {
    return http({
        method: 'GET',
        url: `/app-api/member/cities-districts/getCity?provinceCode=${provinceCode}`,
    })
}
// 逆地址解析
export const getAddress = (data: any) => {
    return http({
        method: 'GET',
        url: 'https://apis.map.qq.com/ws/geocoder/v1/',
        data
    })
}
// 计算距离
export const getDistance = (data: any) => {
    return http({
        method: 'POST',
        url: 'https://apis.map.qq.com/ws/distance/v1/matrix?mode=driving',
        data
    })
}